#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/* Cards finished:
	 7: Adventurer
	 8: Council Room
	 9: Feast
	10: Gardens
	11: Mine
	12: Remodel
	13: Smithy
	14: Village
	15: Baron
	16: Great Hall
	17: Minion
	18: Steward
	19: Tribute
	20: Ambassador
	21: Cutpurse
	22: Embargo
	23: Outpost
	24: Salvager
	25: Sea Hag
	26: Treasure Map
*/


void countCheck(struct gameState G, int player)
{
	printf("handsize: %i, decksize: %i, discardsize: %i\n", G.handCount[player], G.deckCount[player], G.discardCount[player]);
}

void printCards(struct gameState G, int player)
{
	int i;
	
	printf("\nHand: ");
	for(i=0;i<G.handCount[player];i++)
		printf("%i ", G.hand[player][i]);
		
	printf("\nDeck: ");
	for(i=0;i<G.deckCount[player];i++)
		printf("%i ", G.deck[player][i]);
		
	printf("\nDiscard: ");
	for(i=0;i<G.discardCount[player];i++)
		printf("%i ", G.discard[player][i]);
}

// 7
void testAdventurer(struct gameState G, int seed)
{
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 7;
	G.deck[0][0] = 6;
	G.deck[0][1] = 6;
	G.deckCount[0] = 3;
	G.whoseTurn = 0;
	
	playCard(0, 0, 0, 0, &G);
	printf("adventurer> If you get very weird results on this test, close program and reopen.\n");
	printf("adventurer> Testing Adventurer with 2 treasure cards in deck.");
	if(G.hand[0][1] > 3 && G.hand[0][1] < 7 && G.hand[0][2] > 3 && G.hand[0][2] < 7 && G.handCount[0] == 3)
		printf(" PASSED.\n");
	else
		printf(" FAILED.\n");
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 7;
	G.handCount[0] = 1;
	G.deck[0][0] = 6;
	G.deckCount[0] = 1;
	G.discardCount[0] = 1;
	G.discard[0][0] = 6;
	G.whoseTurn = 0;
	playCard(0, 0, 0, 0, &G);
	printf("adventurer> Testing Adventurer with 1 treasure in deck, 1 in discard.");
	if(G.hand[0][1] == 6 && G.hand[0][2] == 6 && G.handCount[0] == 3)
		printf(" PASSED.\n");
	else
		printf(" FAILED.\n");
		
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 7;
	G.deck[0][0] = 7;
	G.deckCount[0] = 1;
	G.discardCount[0] = 1;
	G.discard[0][0] = 7;
	G.whoseTurn = 0;
	playCard(0, 0, 0, 0, &G);
		
	printf("adventurer> Testing Adventurer with inadequate treasures...\n");
	printf("... expecting hand count of 0, received %i.", G.handCount[0]);
	if(G.handCount[0] == 0)
		printf(" PASSED.\n");
	else
		printf(" FAILED.\n");
	printf("... expecting deck count of 0, received %i.", G.deckCount[0]);
	if(G.deckCount[0] == 0)
		printf(" PASSED.\n");
	else
		printf(" FAILED.\n");
	printf("... expecting discard count of 3, received %i.", G.discardCount[0]);
	if(G.discardCount[0] == 3)
		printf(" PASSED.\n");
	else
		printf(" FAILED.\n");
}

// 8
void testCouncilRoom(struct gameState G, int seed)
{
	int k[10] = {council_room, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 3;
	

	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.numBuys = 3;
	G.hand[0][1] = 8;
	G.handCount[1] = 50;
	G.handCount[2] = 0;
	G.whoseTurn = 0;
	
	playCard(1, 0, 0, 0, &G);
	
	printf("council room> Player zero hand expected: 4. Actual: %i. ", G.handCount[0]);
	if(G.handCount[0] == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("council room> Player one hand expected: 51. Actual: %i. ", G.handCount[1]);
	if(G.handCount[1] == 51)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("council room> Player two hand expected: 1. Actual: %i. ", G.handCount[2]);
	if(G.handCount[2] == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("council room> Number of buys expected: 4. Actual: %i ", G.numBuys);
	if(G.numBuys == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

//9
void testFeast(struct gameState G, int seed)
{
	int k[10] = {feast, adventurer, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 9;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	
	playCard(0, 22, 0, 0, &G);
	printf("feast> Playing Feast on a valid supply card. ");
	if(G.discardCount[0] == 1 && G.discard[0][0] == 22)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 9;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	G.supplyCount[6] = -1;  
	
	//playCard(0,6, 0, 0, &G); //<--- Hangs dominion.c
	printf("feast> Playing Feast on card that lacks supply. TEST NOT RUN!\n");
	printf("Assume failure. This test crashes base Dominion program. Cannot check this situation.\n");
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 9;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	//playCard(0, 7, 0, 0, &G); //<--- Results in infinite loop.
	printf("feast> Playing feast on card that is too expensive. TEST NOT RUN!\n");
	printf("Assume failure. This test results in an infinite loop on base Dominion program.\n");
}

// 10
void testGardens(struct gameState G, int seed)
{
	printf("gardens> Gardens doesn't do anything. Check the scoreFor() test, though!\n");
}

// 11
void testMine(struct gameState G, int seed)
{
	int k[10] = {feast, adventurer, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 2;
	G.hand[0][0] = 11;
	G.hand[0][1] = 4;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	G.supplyCount[5] = 10;

	playCard(0, 1, 5, 0, &G);
	printf("mine> Testing card on a valid play...\n");
	printf("... hand should contain valid treasure card. ");
	if(G.hand[0][0] == 5)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... discard count should be 1. It is %i. ", G.discardCount[0]);
	if(G.discardCount[0] == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... supply count should now be 9. It is %i. ", G.supplyCount[5]);
	if(G.supplyCount[5] == 9)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 2;
	G.hand[0][0] = 11;
	G.hand[0][1] = 4;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	G.supplyCount[6] = 10;
	
	playCard(0, 1, 6, 0, &G);
	printf("mine> Testing mine on card that is too expensive...\n");
	printf("... hand count should still be 2. It is %i. ", G.handCount[0]);
	if(G.handCount[0] == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... supply count should still be 10. It is %i. ", G.supplyCount[6]);
	if(G.supplyCount[6] == 10)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

// 12
void testRemodel(struct gameState G, int seed)
{
	int k[10] = {remodel, adventurer, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 2;
	G.hand[0][0] = 12;
	G.hand[0][1] = 4;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	G.supplyCount[7] = 10;
	
	playCard(0, 1, 7, 0, &G);
	printf("remodel> Trying to remodel 0 into 6 (invalid move)...\n");
	printf("... hand should still be 2. It is %i. ", G.handCount[0]);
	if(G.handCount[0] == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... discard count should still be 0. It is %i. ", G.discardCount[0]);
	if(G.discardCount[0] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 2;
	G.hand[0][0] = 12;
	G.hand[0][1] = 12;
	G.whoseTurn = 0;
	G.deckCount[0] = 0;
	G.discardCount[0] = 0;
	G.supplyCount[4] = 10;
	
	playCard(0, 1, 4, 0, &G);
	printf("remodel> Trying to remodel 6 into cost 0 (valid move)...\n");
	printf("... hand should drop to 0. It is %i. ", G.handCount[0]);
	if(G.handCount[0] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... discard count should now be 1. It is %i. ", G.discardCount[0]);
	if(G.discardCount[0] == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

// 13
void testSmithy(struct gameState G, int seed)
{
	int k[10] = {remodel, adventurer, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	
	initializeGame(numPlayer, k, seed, &G);
	G.handCount[0] = 1;
	G.hand[0][0] = 13;
	G.deckCount[0] = 3;
	G.discardCount[0] = 1;
	G.whoseTurn = 0;
	
	playCard(0,0,0,0,&G);
	printf("smithy> Playing smithy card, checking for 3 drawn cards. ");
	if(G.deckCount[0] == 0 && G.discardCount[0] == 1 && G.handCount[0] == 3)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}
// 14
void testVillage(struct gameState G, int seed)
{
	int k[10] = {council_room, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 3;
	
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.numActions = 1;
	G.hand[0][0] = 14;
	
	playCard(0, 0, 0, 0, &G);
	printf("village> Expected hand count: 1. Actual: %i. ", G.handCount[0]);
	if(G.handCount[0] == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("village> Expected actions: 2. Actual: %i. ", G.numActions);
	if(G.numActions == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

// 15
void testBaron(struct gameState G, int seed)
{
	int k[10] = {baron, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.numActions = 1;
	G.hand[0][0] = 15;
	G.supplyCount[1] = 10;
	G.deckCount[0] = 5;
	G.numBuys = 1;
	
	printf("baron> Testing buy gained. ");
	playCard(0, 0, 0, 0, &G);
	if(G.numBuys == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		printf("baron> Testing estate gained to discard on no discard. ");
	if(G.discardCount[0] == 1 && G.discard[0][0] == 1)
		printf("PASSED.\n");
	else
		printf("PASSED.\n");
	
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 2;
	G.numActions = 1;
	G.hand[0][0] = 15;
	G.hand[0][1] = 1;
	G.supplyCount[1] = 10;
	G.deckCount[0] = 5;
	G.numBuys = 1;
	G.coins = 0;
	
	printf("baron> Testing +4 coins on estate discard. ");
	playCard(0, 1, 0, 0, &G);
	if(G.coins == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("baron> Checking that estate was discarded. ");
	if(G.discard[0][0] == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

// 16
void testGreatHall(struct gameState G, int seed)
{
	int k[10] = {great_hall, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 5;
	G.hand[0][0] = 16;
	G.numActions = 1;
	
	playCard(0, 0, 0, 0, &G);
	
	printf("great hall> Testing card drawn. Expecting %i, received %i. ", 5, G.handCount[0]);
	if(G.handCount[0] == 5)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("great hall> Testing actions. Expecting 1, received %i. ", G.numActions);
	if(G.numActions == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("great hall> Ensuring card was played. ");
	if(G.hand[0][0] == 16)
		printf("FAILED.\n");
	else
		printf("PASSED.\n");
}

// 17
void testMinion(struct gameState G, int seed)
{
	int k[10] = {minion, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 17;
	G.numActions = 2;
	G.coins = 0;
	
	
	playCard(0, 1, 0, 0, &G);
	printf("minion> Expecting 2 actions after playing card, have %i actions. ", G.numActions);
	if(G.numActions == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("minion> Expecting 2 coins for not discarding. Received %i. ", G.coins);
	if(G.coins == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	numPlayer = 3;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 17;
	G.handCount[1] = 5;
	G.handCount[2] = 3;
	G.numActions = 1;
	G.coins = 0;
	
	printf("minion> Testing discard option of minion...\n");
	playCard(0, 0, 1, 0, &G);
	printf("... testing player's redraw. Expecting size 4, recieved %i. ", G.handCount[0]);
	if(G.handCount[0] == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... testing opponent with 5 cards. Expecting 4 cards, recieved %i. ", G.handCount[1]);
	if(G.handCount[1] == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... testing opponent with 3 cards. Expecting 3 cards, received %i. ", G.handCount[2]);
	if(G.handCount[2] == 3)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

// 18
void testSteward(struct gameState G, int seed)
{
	int k[10] = {steward, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, tribute, smithy};
	int numPlayer = 2;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 18;
	G.coins = 0;
	G.numActions = 2;
	
	playCard(0, 1, 0, 0, &G);
	printf("steward> Testing redraw function. Expecting 2 cards, have %i. ", G.handCount[0]);
	if(G.handCount[0] == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	G.handCount[0] = 1;
	G.hand[0][0] = 18;
	G.coins = 0;
	playCard(0, 2, 0, 0, &G);
	printf("steward> Testing coins function. Expecting 2 coins, have %i. ", G.coins);
	if(G.coins == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
	G.handCount[0] = 5;
	G.hand[0][0] = 18;
	G.hand[0][1] = 1;
	G.hand[0][2] = 4;
	G.hand[0][3] = 4;
	G.hand[0][4] = 1;
	G.discardCount[0] = 0;
	G.coins = 0;
	playCard(0, 0, 2, 3, &G);
	printf("steward> Testing discard function with hand size 5 and no discard pile...\n");
	printf("... seeing if discard increased by 2. It is %i. ", G.discardCount[0]);
	if(G.discardCount[0] == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... expecting hand size of 3, received %i. ", G.handCount[0]);
	if(G.handCount[0] == 3)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

//19
void testTribute(struct gameState G, int seed)
{
	int k[10] = {tribute, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, steward, smithy};
	int numPlayer = 2;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 19;
	G.coins = 0;
	G.numActions = 0;
	G.deckCount[1] = 2;
	G.deck[1][0] = 19;
	G.deck[1][1] = 19;
	
	playCard(0, 0, 0, 0, &G);
	printf("tribute> Testing Tribute with various cards shown...\n");
	printf("... with Action cards, expecting 4 actions, received %i. ", G.numActions);
	if(G.numActions == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
	initializeGame(numPlayer, k, seed, &G);	
	G.handCount[0] = 1;
	G.hand[0][0] = 19;
	G.coins = 0;
	G.numActions = 1;
	G.deckCount[1] = 2;
	G.deck[1][0] = 5;
	G.deck[1][1] = 6;
	
	playCard(0, 0, 0, 0, &G);
	printf("... with Treasure cards, expecting 4 coins, received %i. ", G.coins);
	if(G.coins == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
	initializeGame(numPlayer, k, seed, &G);	
	G.handCount[0] = 1;
	G.hand[0][0] = 19;
	G.coins = 0;
	G.numActions = 1;
	G.deckCount[1] = 2;
	G.deck[1][0] = 3;
	G.deck[1][1] = 3;
	
	playCard(0, 0, 0, 0, &G);
	printf("... with Victory cards, expecting 4 hand size, have %i. ", G.handCount[0]);
	if(G.handCount[0] == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

//20
void testAmbassador(struct gameState G, int seed)
{
	int k[10] = {ambassador, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, steward, smithy};
	int numPlayer = 3;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 3;
	G.hand[0][0] = 20;
	G.hand[0][1] = 5;
	G.hand[0][2] = 5;
	G.supplyCount[5] = 10;
	
	playCard(0, 2, 2, 0, &G);
	printf("ambassador> Checking to see if cards taken from hand. ");
	if(G.handCount[0] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("ambassador> Seeing if supply changed by one (+2, -3). ");
	if(G.supplyCount[5] == 9)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

//21
void testCutpurse(struct gameState G, int seed)
{
	int k[10] = {cutpurse, gardens, embargo, village, great_hall, mine, outpost, sea_hag, steward, smithy};
	int numPlayer = 3;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 21;
	G.handCount[1] = 1;
	G.hand[1][0] = 4;
	G.handCount[2] = 1;
	G.hand[2][0] = 4;
	G.coins = 0;
	
	playCard(0, 0, 0, 0, &G);
	printf("cutpurse> Seeing if 2 coins gained. ");
	if(G.coins == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("cutpurse> Seeing if player two discarded copper. ");
	if(G.handCount[1] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("cutpurse> Seeing if player three discarded copper. ");
	if(G.handCount[2] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

//22
void testEmbargo(struct gameState G, int seed)
{
	int k[10] = {embargo, gardens, cutpurse, village, great_hall, mine, cutpurse, sea_hag, steward, smithy};
	int numPlayer = 2;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 22;
	G.coins = 0;
	G.supplyCount[6] = 10;
	G.embargoTokens[6] = 1;
	
	playCard(0, 6, 0, 0, &G);
	printf("embargo> Expecting 2 coins, received %i. ", G.coins);
	if(G.coins == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("embargo> Embargoing again: Expecting 2 embargoes, actually has %i. ", G.embargoTokens[6]);
	if(G.embargoTokens[6] == 2)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 22;
	G.coins = 0;
	G.supplyCount[6] = 10;
	G.embargoTokens[6] = 0;
	
	playCard(0, 6, 0, 0, &G);
	printf("embargo> Embargoing new: Expecting 1 embargoes, actually has %i. ", G.embargoTokens[6]);
	if(G.embargoTokens[6] == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
		
	printf("embargo> To test embargo effect, please test buyCard().\n");
}

//23
void testOutpost(struct gameState G, int seed)
{
	int k[10] = {outpost, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, steward, smithy};
	int numPlayer = 3;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 23;
	G.outpostPlayed = 0;
	
	playCard(0, 0, 0, 0, &G);
	
	printf("outpost> Seeing if game registered an outpost was played. ");
	if(G.outpostPlayed == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("outpost> Note, Outpost effect appears to be NYI.\n");
}

//24
void testSalvager(struct gameState G, int seed)
{
	int k[10] = {salvager, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, steward, smithy};
	int numPlayer = 3;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 2;
	G.hand[0][0] = 24;
	G.hand[0][1] = 6;
	G.outpostPlayed = 0;
	G.coins = 0;
	G.numBuys = 0;
	
	playCard(0, 1, 0, 0, &G);
	printf("salvager> Trashing a gold card (cost 6)...\n");
	printf("... seeing if +1 buy gained. ");
	if(G.numBuys == 1)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... seeing if gold card was trashed. ");
	if(G.handCount[0] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... expecting 6 coins, received %i. ", G.coins);
	if(G.coins == 6)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
}

//25
void testSeaHag(struct gameState G, int seed)
{
	int k[10] = {sea_hag, gardens, embargo, village, great_hall, mine, cutpurse, treasure_map, steward, smithy};
	int numPlayer = 3;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 25;
	G.deckCount[0] = 5;
	G.deckCount[1] = 4;
	G.deckCount[2] = 3;
	G.supplyCount[0] = 10;
	
	playCard(0, 0, 0, 0, &G);
	
	printf("sea hag> Playing Sea Hag with 3 players in game...\n");
	printf("... ensuring player 1 did not receive curse. ");
	if(G.deck[0][0] == 0)
		printf("FAILED.\n");
	else
		printf("PASSED.\n");
	printf("... player 2's deck size should stay 4. It is %i. ", G.deckCount[1]);
	if(G.deckCount[1] == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... player 3's deck size should stay 3. It is %i. ", G.deckCount[2]);
	if(G.deckCount[2] == 3)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... checking if all other players received curse. ");
	if(G.deck[1][0] == 0 && G.deck[2][0] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... Curse supply should be 8, it is %i. ", G.supplyCount[0]);
	if(G.supplyCount[0] == 8)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
}
//26
void testTreasureMap(struct gameState G, int seed)
{
	int k[10] = {treasure_map, gardens, embargo, village, great_hall, mine, cutpurse, sea_hag, steward, smithy};
	int numPlayer = 2;
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 1;
	G.hand[0][0] = 26;
	
	playCard(0, 0, 0, 0, &G);
	
	printf("treasure map> Playing a single treasure map. (Trash itself.) ");
	if(G.handCount[0] == 0)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("treasure map> Playing two treasure maps...\n");
	
	initializeGame(numPlayer, k, seed, &G);
	
	G.handCount[0] = 2;
	G.hand[0][0] = 26;
	G.hand[0][1] = 26;
	G.deckCount[0] = 0;
	G.supplyCount[6] = 10;
	
	playCard(0, 0, 0, 0, &G);
	printf("... seeing if deck increased by 4. Increased by %i. ", G.deckCount[0]);
	if(G.deckCount[0] == 4)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... seeing if those 4 cards are gold. ");
	if(G.deck[0][0] == 6 && G.deck[0][1] == 6 && G.deck[0][2] == 6 && G.deck[0][3] == 6)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	printf("... seeing if gold supply decreased by 4. ");
	if(G.supplyCount[6] == 6)
		printf("PASSED.\n");
	else
		printf("FAILED.\n");
	
}

void doAll(struct gameState G, int seed)
{
	testAdventurer(G, seed);
	testCouncilRoom(G, seed);
	testFeast(G, seed);
	testGardens(G, seed);
	testMine(G, seed);
	testRemodel(G, seed);
	testSmithy(G, seed);
	testVillage(G, seed);
	testBaron(G, seed);
	testGreatHall(G, seed);
	testMinion(G, seed);
	testSteward(G, seed);
	testTribute(G, seed);
	testAmbassador(G, seed);
	testCutpurse(G, seed);
	testEmbargo(G, seed);
	testOutpost(G, seed);
	testSalvager(G, seed);
	testSeaHag(G, seed);
	testTreasureMap(G, seed);
}

int main(int argc, char *argv[])
{
	char txtin[255];
	int seed;
	struct gameState G;
	
	srand(time(NULL));
	seed = (rand() % 1000)+1;
	
	printf("Valid commands for Test Card Function:\n");
	printf("Enter a number between 7 and 26 to test that card.\n");
	printf("Enter \"all\" to test all cards.\n");
	printf("Enter \"quit\" to exit program.\n");

	while(1)
	{

		printf("command> ");
		fgets(txtin, 255, stdin);
		if(strcmp(txtin, "quit\n") == 0)
			exit(0);
		if(strcmp(txtin, "7\n") == 0)
			testAdventurer(G, seed);
		if(strcmp(txtin, "8\n") == 0)
			testCouncilRoom(G, seed);
		if(strcmp(txtin, "9\n") == 0)
			testFeast(G, seed);
		if(strcmp(txtin, "10\n") == 0)
			testGardens(G, seed);
		if(strcmp(txtin, "11\n") == 0)
			testMine(G, seed);
		if(strcmp(txtin, "12\n") == 0)
			testRemodel(G, seed);
		if(strcmp(txtin, "13\n") == 0)
			testSmithy(G, seed);
		if(strcmp(txtin, "14\n") == 0)
			testVillage(G, seed);
		if(strcmp(txtin, "15\n") == 0)
			testBaron(G, seed);
		if(strcmp(txtin, "16\n") == 0)
			testGreatHall(G, seed);
		if(strcmp(txtin, "17\n") == 0)
			testMinion(G, seed);
		if(strcmp(txtin, "18\n") == 0)
			testSteward(G, seed);
		if(strcmp(txtin, "19\n") == 0)
			testTribute(G, seed);
		if(strcmp(txtin, "20\n") == 0)
			testAmbassador(G, seed);
		if(strcmp(txtin, "21\n") == 0)
			testCutpurse(G, seed);
		if(strcmp(txtin, "22\n") == 0)
			testEmbargo(G, seed);
		if(strcmp(txtin, "23\n") == 0)
			testOutpost(G, seed);
		if(strcmp(txtin, "24\n") == 0)
			testSalvager(G, seed);
		if(strcmp(txtin, "25\n") == 0)
			testSeaHag(G, seed);
		if(strcmp(txtin, "26\n") == 0)
			testTreasureMap(G, seed);
		if(strcmp(txtin, "all\n") == 0)
			doAll(G, seed);
	}
}

